package b_deep.example2;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.io.FileUtils;

import com.alibaba.fastjson.JSON;
import com.wang.template.json.JsonLoader;
import com.wang.template.json.JsonRender;
import com.wang.template.json.node.BaseNode;

public class DeepExample2 {
	public static void main(String[] args) throws Exception { 
		Map<String, Object> dataSource = new HashMap<String, Object>();
		String jsonStr = FileUtils.readFileToString(new File(DeepExample2.class.getResource("json.json").getPath()), "UTF-8");
		BaseNode node = JsonLoader.load(jsonStr);
		dataSource.put("retCode", "000000");
		dataSource.put("retMsg", "服务执行成功");
		Map<String, String> data = new HashMap<String, String>();
		data.put("goodsId", "1111111");
		data.put("goodsName", "商品名称");
		Map<String, Object> data1 = new HashMap<String, Object>();
		data1.put("data", data);
		dataSource.put("data", data1);
		long start = System.currentTimeMillis();
		Object obj = JsonRender.render(node, dataSource);
		System.out.println("耗时" + (System.currentTimeMillis() - start) + JSON.toJSONString(obj, true));

	}
}
